package cn.stylefeng.guns.modular.yingbao.controller;

import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
import  cn.stylefeng.guns.modular.yingbao.entity.UserPay;
import  cn.stylefeng.guns.modular.yingbao.model.params.UserPayParam;
import  cn.stylefeng.guns.modular.yingbao.service.UserPayService;
import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.core.reqres.response.ResponseData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import oracle.jdbc.proxy.annotation.Post;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;


/**
 * 用户收款信息表控制器
 *
 * @author zs
 * @Date 2019-12-12 14:01:48
 */
@CrossOrigin
@Controller
@RequestMapping("/userPay")
@Api(tags = "用户收款信息")
public class UserPayController extends BaseController {

    private String PREFIX = "/userPay";

    @Autowired
    private UserPayService userPayService;

    /**
     * 跳转到主页面
     *
     * @author zs
     * @Date 2019-12-12
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "/userPay.html";
    }

    /**
     * 新增页面
     *
     * @author zs
     * @Date 2019-12-12
     */
    @RequestMapping("/add")
    public String add() {
        return PREFIX + "/userPay_add.html";
    }

    /**
     * 编辑页面
     *
     * @author zs
     * @Date 2019-12-12
     */
    @RequestMapping("/edit")
    public String edit() {
        return PREFIX + "/userPay_edit.html";
    }

    /**
     * 新增接口
     *
     * @author zs
     * @Date 2019-12-12
     */
    @RequestMapping("/addItem")
    @ResponseBody
    public ResponseData addItem(UserPayParam userPayParam) {
        this.userPayService.add(userPayParam);
        return ResponseData.success();
    }

    /**
     * 编辑接口
     *
     * @author zs
     * @Date 2019-12-12
     */
    @RequestMapping("/editItem")
    @ResponseBody
    public ResponseData editItem(UserPayParam userPayParam) {
        this.userPayService.update(userPayParam);
        return ResponseData.success();
    }

    /**
     * 删除接口
     *
     * @author zs
     * @Date 2019-12-12
     */
    @RequestMapping("/delete")
    @ResponseBody
    public ResponseData delete(UserPayParam userPayParam) {
        this.userPayService.delete(userPayParam);
        return ResponseData.success();
    }

    /**
     * 查看详情接口
     *
     * @author zs
     * @Date 2019-12-12
     */
    @RequestMapping("/detail")
    @ResponseBody
    public ResponseData detail(UserPayParam userPayParam) {
        UserPay detail = this.userPayService.getById(userPayParam.getId());
        return ResponseData.success(detail);
    }

    /**
     * 查询列表
     *
     * @author zs
     * @Date 2019-12-12
     */
    @ResponseBody
    @RequestMapping("/list")
    public LayuiPageInfo list(UserPayParam userPayParam) {
        return this.userPayService.findPageBySpec(userPayParam);
    }


    @PostMapping("queryByName")
    @ResponseBody
    @ApiOperation("查询可以创建的收款方式")
    @ApiImplicitParam(name = "userid",value = "用户id")
    public ResponseData queryByName(String userid){
        return this.userPayService.queryByName(userid);
    }

    @PostMapping("addPay")
    @ResponseBody
    @ApiOperation("添加收账信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userid",value = "用户id"),
            @ApiImplicitParam(name = "name",value = "收款方式 直接写汉字"),
            @ApiImplicitParam(name = "account",value = "账号()"),
            @ApiImplicitParam(name = "pic",value = "收款二维码(银行卡号)"),
            @ApiImplicitParam(name = "phone",value = "联系电话"),
            @ApiImplicitParam(name = "bankid",value = "开户行id"),
            @ApiImplicitParam(name = "username",value = "姓名"),
    })
    public ResponseData addPay(UserPay userPay){
        return this.userPayService.addPay(userPay);
    }

    @PostMapping("delPayId")
    @ApiOperation("删除收款信息")
    @ResponseBody
    @ApiImplicitParam(name = "id" , value = "收款信息id")
    public ResponseData delPayId(String id){
        return this.userPayService.delPayid(id);
    }

    @PostMapping("upUserPay")
    @ResponseBody
    @ApiOperation("修改收账信息")
    public ResponseData upUserPay(UserPay userPay){
        return this.userPayService.upUserPay(userPay);
    }

    @PostMapping("queryByUserId")
    @ResponseBody
    @ApiOperation("查看自己的所有收账信息")
    @ApiImplicitParam(name = "userid",value = "用户id")
    public ResponseData queryByUserId(String userid){
        return this.userPayService.queryByUserId(userid);
    }

    @PostMapping("queryById")
    @ResponseBody
    @ApiOperation("查看具体那条信息")
    @ApiImplicitParam(name = "id",value = "主键id")
    public ResponseData queryById(Long id){
        return this.userPayService.queryById(id);
    }

    @PostMapping("queryByUserIdAndName")
    @ResponseBody
    @ApiOperation("存在与否？")
    @ApiImplicitParam(name = "payid",value = "支付方式1,微信,2,支付宝,3银行卡")
    public ResponseData queryByUserIdAndName(String userid,String payid){
        return this.userPayService.queryByUserIdAndName(userid,payid);
    }

    @PostMapping("upStatus")
    @ResponseBody
    @ApiOperation("后台审核")
    public ResponseData upStatus(String id){
        return this.userPayService.upStatus(id);
    }

    @PostMapping("queryAll1")
    @ResponseBody
    public List<UserPay> queryAll1(Long userid){
        return userPayService.queryAll1(userid);
    }

}


